package com.huawei.appgallery.appcomment.ui;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.appcomment.impl.bean.CommentReportResBean;
import com.huawei.appgallery.appcomment.ui.adapter.ReportTypeAdapter;
import com.huawei.appgallery.appcomment.ui.view.FoldTextView;
import com.huawei.appgallery.appcomment.ui.view.HeadImageView;
import com.huawei.appgallery.appcomment.ui.view.NoScrollListView;
import com.huawei.appgallery.foundation.ui.framework.widget.RenderRatingBar;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import huawei.widget.HwEditText;
import huawei.widget.HwTextView;
import o.azb;
import o.bcb;
import o.bcg.c;
import o.bcg.d;
import o.bcg.e;
import o.bcg.h;
import o.bcy;
import o.beg;
import o.ber;
import o.cfw;
import o.BaseRequest;
import o.doo;
import o.equ;
import o.evk;

public class AppReportActivity extends Activity implements IServerCallBack {
    private RenderRatingBar ʻ;
    private ProgressBar ʼ;
    private HwTextView ʽ;
    private HwEditText ˊ;
    private NoScrollListView ˊॱ;
    int ˋ = 2;
    private LinearLayout ˋॱ;
    int ˎ = 1;
    int ˏ = 0;
    private beg ͺ;
    private HwTextView ॱ;
    private ReportTypeAdapter ॱˊ;
    private FoldTextView ॱॱ;
    private HeadImageView ᐝ;

    protected void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        requestWindowFeature(1);
        setContentView(d.ॱᐝ);
        this.ͺ = (beg) getIntent().getSerializableExtra("reportContentInfo");
        ˋ();
        ॱ();
        ˊ();
    }

    private void ˋ() {
        View view = (ViewGroup) findViewById(e.ʾˊ);
        azb.ˏ(view);
        ((HwTextView) view.findViewById(e.ˉˋ)).setText(getString(h.ʻˋ));
        ((ImageView) view.findViewById(e.ˊˉ)).setImageDrawable(getResources().getDrawable(c.ˊॱ));
        view.findViewById(e.ᶥॱ).setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ AppReportActivity ॱ;

            {
                this.ॱ = r1;
            }

            public void onClick(View view) {
                this.ॱ.finish();
            }
        });
        this.ˋॱ = (LinearLayout) view.findViewById(e.ⁱ);
        ((ImageView) view.findViewById(e.ﹳॱ)).setImageDrawable(getResources().getDrawable(c.ˏॱ));
        this.ˋॱ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ AppReportActivity ˏ;

            {
                this.ˏ = r1;
            }

            public void onClick(View view) {
                this.ˏ.ˏ();
            }
        });
        this.ʼ = (ProgressBar) view.findViewById(e.ˈˋ);
    }

    private void ॱ() {
        this.ॱ = (HwTextView) findViewById(e.ॱﹳ);
        this.ˊ = (HwEditText) findViewById(e.ᐧॱ);
        this.ᐝ = (HeadImageView) findViewById(e.ʽʻ);
        this.ʻ = (RenderRatingBar) findViewById(e.ʼʻ);
        this.ॱॱ = (FoldTextView) findViewById(e.ˋʻ);
        View view = (TextView) findViewById(e.ॱﾟ);
        this.ˊॱ = (NoScrollListView) findViewById(e.ʽʽ);
        this.ʽ = (HwTextView) findViewById(e.ꜝ);
        azb.ˏ(this.ᐝ);
        azb.ˏ(this.ॱॱ);
        azb.ˏ(view);
        azb.ˏ(this.ˊ);
        azb.ˏ(this.ˊॱ);
        azb.ˏ(this.ˊॱ, e.ˇ);
        this.ʽ.setText(h.ʼˋ);
        if (this.ॱˊ == null) {
            this.ॱˊ = new ReportTypeAdapter(this);
        }
        this.ˊॱ.setAdapter(this.ॱˊ);
    }

    private void ˊ() {
        if (this.ͺ == null) {
            finish();
            return;
        }
        if (TextUtils.isEmpty(this.ͺ.ˋ())) {
            this.ᐝ.setImageResource(c.ᐝॱ);
        } else {
            equ.ˊ(this.ᐝ, this.ͺ.ˋ(), "head_default_icon");
        }
        this.ॱ.setText(this.ͺ.ˎ());
        this.ॱॱ.setText(this.ͺ.ˊ());
        this.ॱॱ.setMaxLine(3);
        this.ॱॱ.setContent(new SpannableStringBuilder(this.ͺ.ˊ()), false, ber.ˏ(this.ॱॱ));
        float f = 0.0f;
        try {
            f = Float.parseFloat(this.ͺ.ᐝ());
        } catch (NumberFormatException e) {
            bcb.ˋ.ˏ("", "rating value NumberFormatException, rating:" + this.ͺ.ᐝ());
        }
        this.ʻ.setRating(f);
    }

    private void ˊ(boolean z) {
        int i;
        int i2 = 8;
        boolean z2 = false;
        ProgressBar progressBar = this.ʼ;
        if (z) {
            i = 0;
        } else {
            i = 8;
        }
        progressBar.setVisibility(i);
        LinearLayout linearLayout = this.ˋॱ;
        if (!z) {
            i2 = 0;
        }
        linearLayout.setVisibility(i2);
        NoScrollListView noScrollListView = this.ˊॱ;
        if (!z) {
            z2 = true;
        }
        noScrollListView.setEnabled(z2);
    }

    private void ˏ() {
        Object checkedReport = this.ॱˊ.getCheckedReport();
        if (TextUtils.isEmpty(checkedReport)) {
            evk.ॱ(getString(h.ﹳ), 0).ˋ();
        } else if (doo.ˊ((Context) this)) {
            ˊ(true);
            cfw.ˎ(new bcy(this.ͺ.ˏ(), checkedReport, this.ˊ.getText().toString(), this.ͺ.ॱ()), this);
        } else {
            evk.ˏ(this, h.ᐝʽ, 0).ˋ();
        }
    }

    public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
    }

    public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
        ˊ(false);
        if (!(responseBean instanceof CommentReportResBean)) {
            return;
        }
        if (responseBean.getRtnCode_() == 0) {
            evk.ॱ(getString(h.ʻᐝ), 0).ˋ();
            finish();
            return;
        }
        evk.ॱ(getString(h.ﾞ), 0).ˋ();
    }
}
